#include <stdio.h>
void bubble(int arr[],int sz)
{
	int i = 0;
	int tmp = 0;
	int n = 0;

	for (i = 0; i < sz - 1 ; i++)
	{
		for (n = 0; n < sz - i -1; n++)
		{
			if (arr[n] > arr[n + 1])
			{
				tmp = arr[n];
				arr[n] = arr[n + 1];
				arr[n + 1] = tmp;
			}
		
		}
	}
}

int main()
{
    int arr1[1000] = {0};
    int arr2[1000] = {0};
    int sum[30000] = {0};
    int n = 0;
    int m = 0;
    int i = 0;
    int j = 0;
    int rem = 0;
    int tmp = 0;
    
    scanf ("%d %d",&n,&m);
    for(i = 0; i < n ; i++)
    {
        scanf("%d",&arr1[i]);
    }
    for(i=0; i<m; i++)
    {
        scanf("%d",&arr2[i]);
    }
    
    for(i = 0;i<n;i++)
    {
        sum[i] = arr1[i];
    }
        j = n;

    for(i = 0;i<m;i++)
    {
        sum[j] = arr2[i];
        j++;
    }
    
    bubble(sum,n+m);
    for(i=0; i<m+n; i++)
    {
       printf ("%d ",sum[i]);
    }
    
    return 0;
    
}